<?php

/**
 * Defis form base class.
 *
 * @method Defis getObject() Returns the current form's model object
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDefisForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'titre'         => new sfWidgetFormTextarea(),
      'description'   => new sfWidgetFormTextarea(),
      'etat'          => new sfWidgetFormChoice(array('choices' => array('disable' => 'disable', 'running' => 'running', 'terminate' => 'terminate'))),
      'valide'        => new sfWidgetFormInputText(),
      'date_en_ligne' => new sfWidgetFormDateTime(),
      'date_creation' => new sfWidgetFormDateTime(),
      'date_fin'      => new sfWidgetFormDateTime(),
      'users_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Users'), 'add_empty' => false)),
      'nb_inscrit'    => new sfWidgetFormInputText(),
      'ordre'         => new sfWidgetFormInputText(),
      'difficulte'    => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'titre'         => new sfValidatorString(),
      'description'   => new sfValidatorString(),
      'etat'          => new sfValidatorChoice(array('choices' => array(0 => 'disable', 1 => 'running', 2 => 'terminate'), 'required' => false)),
      'valide'        => new sfValidatorInteger(array('required' => false)),
      'date_en_ligne' => new sfValidatorDateTime(),
      'date_creation' => new sfValidatorDateTime(),
      'date_fin'      => new sfValidatorDateTime(),
      'users_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Users'))),
      'nb_inscrit'    => new sfValidatorInteger(),
      'ordre'         => new sfValidatorInteger(),
      'difficulte'    => new sfValidatorInteger(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('defis[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Defis';
  }

}
